import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        int q = in.nextInt();
        int[] nums = new int[n+1];
        long[] dp = new long[n+1];//防溢出
        for (int i = 1;i < nums.length;i++) {
            nums[i] = in.nextInt();
        }
        for (int i = 1;i < nums.length;i++) {
            //构造前缀数组
            dp[i] = dp[i-1] + nums[i];
        }
        for (int j = 0;j < q;j++) { // 注意 while 处理多个 case
            int left = in.nextInt();
            int right = in.nextInt();
            System.out.println(dp[right] - dp[left-1]);
        }
    }
}